/*     */ package com.zimbra.cs.redolog.op;
/*     */ 
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.MailboxManager;
/*     */ import com.zimbra.cs.mailbox.MailboxOperation;
/*     */ import com.zimbra.cs.redolog.RedoLogInput;
/*     */ import com.zimbra.cs.redolog.RedoLogOutput;
/*     */ import com.zimbra.cs.redolog.Version;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class RenameItemPath
/*     */   extends RedoableOp
/*     */ {
/*     */   protected int mId;
/*     */   protected MailItem.Type type;
/*     */   protected String mPath;
/*     */   protected int[] mParentIds;
/*     */   protected String[] mParentUuids;
/*     */   
/*     */   public RenameItemPath()
/*     */   {
/*  40 */     super(MailboxOperation.RenameItemPath);
/*  41 */     this.mId = 0;
/*  42 */     this.type = MailItem.Type.UNKNOWN;
/*     */   }
/*     */   
/*     */   public RenameItemPath(int mailboxId, int id, MailItem.Type type, String path) {
/*  46 */     this();
/*  47 */     setMailboxId(mailboxId);
/*  48 */     this.mId = id;
/*  49 */     this.type = type;
/*  50 */     this.mPath = (path != null ? path : "");
/*     */   }
/*     */   
/*     */   public int[] getParentIds() {
/*  54 */     return this.mParentIds;
/*     */   }
/*     */   
/*     */   public String[] getParentUuids() {
/*  58 */     return this.mParentUuids;
/*     */   }
/*     */   
/*     */   public void setParentIdsAndUuids(int[] parentIds, String[] parentUuids) {
/*  62 */     this.mParentIds = parentIds;
/*  63 */     this.mParentUuids = parentUuids;
/*     */   }
/*     */   
/*     */   protected String getPrintableData()
/*     */   {
/*  68 */     StringBuilder sb = new StringBuilder("id=");
/*  69 */     sb.append(this.mId).append(", type=").append(this.type).append(", path=").append(this.mPath);
/*  70 */     if (this.mParentIds != null) {
/*  71 */       sb.append(", destParentIdsAndUuids=[");
/*  72 */       for (int i = 0; i < this.mParentIds.length; i++) {
/*  73 */         sb.append(this.mParentIds[i]).append(" (").append(this.mParentUuids[i]).append(")");
/*  74 */         if (i < this.mParentIds.length - 1) {
/*  75 */           sb.append(", ");
/*     */         }
/*     */       }
/*  78 */       sb.append("]");
/*     */     }
/*  80 */     return sb.toString();
/*     */   }
/*     */   
/*     */   protected void serializeData(RedoLogOutput out) throws IOException
/*     */   {
/*  85 */     out.writeInt(this.mId);
/*  86 */     out.writeUTF(this.mPath);
/*  87 */     if (this.mParentIds != null) {
/*  88 */       out.writeInt(this.mParentIds.length);
/*  89 */       for (int i = 0; i < this.mParentIds.length; i++) {
/*  90 */         out.writeInt(this.mParentIds[i]);
/*  91 */         if (getVersion().atLeast(1, 37)) {
/*  92 */           out.writeUTF(this.mParentUuids[i]);
/*     */         }
/*     */       }
/*     */     } else {
/*  96 */       out.writeInt(0);
/*     */     }
/*  98 */     out.writeByte(this.type.toByte());
/*     */   }
/*     */   
/*     */   protected void deserializeData(RedoLogInput in) throws IOException
/*     */   {
/* 103 */     this.mId = in.readInt();
/* 104 */     this.mPath = in.readUTF();
/* 105 */     int numParentIds = in.readInt();
/* 106 */     if (numParentIds > 0) {
/* 107 */       this.mParentIds = new int[numParentIds];
/* 108 */       this.mParentUuids = new String[numParentIds];
/* 109 */       for (int i = 0; i < numParentIds; i++) {
/* 110 */         this.mParentIds[i] = in.readInt();
/* 111 */         if (getVersion().atLeast(1, 37)) {
/* 112 */           this.mParentUuids[i] = in.readUTF();
/*     */         }
/*     */       }
/*     */     }
/* 116 */     this.type = MailItem.Type.of(in.readByte());
/*     */   }
/*     */   
/*     */   public void redo() throws Exception
/*     */   {
/* 121 */     Mailbox mailbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/* 122 */     mailbox.rename(getOperationContext(), this.mId, this.type, this.mPath);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/RenameItemPath.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */